package org.vector.view;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import org.vector.serviceImpl.BankServiceImpl;

@SuppressWarnings("serial")
public class DaytoDay extends JFrame {
	BankServiceImpl bsi = new BankServiceImpl();
	private JLabel jlabel;
	private JButton button;
	private JScrollPane tablepane;
	private JTable table;
	//需要把数据弄到数组里
	String[][] data = null;  //表格数据
	String[] cols = {"流水单号","用户","目标用户","金额","服务费","服务类型","交易时间"};//表格标题
	
	public DaytoDay() {}
	public DaytoDay(int bankid) {
		into(bankid);
		setVisible(true);
		setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
	}
	private void into(int bankid) {
		setSize(1000, 700);
		setLocationRelativeTo(null);
		setLayout(null);
		jlabel = new JLabel("近期流水单");
		jlabel.setBounds(300, 50, 100, 25);
		add(jlabel);
		
		table = new JTable(40, 7);
		table.getTableHeader().setReorderingAllowed(false);//不可改变列顺序
		table.getTableHeader().setResizingAllowed(false);//不可改变列宽
		
		tablepane = new JScrollPane(table);
		tablepane.setBounds(30, 75, 900, 500);
		add(tablepane);
		
		data = bsi.getRecord(bankid);
		DefaultTableModel tableModel = new DefaultTableModel(data, cols);
		table.setModel(tableModel);
		
		button = new JButton("返回");
		button.setBounds(450, 580, 80, 60);
		add(button);
		
		button.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0) {
				DaytoDay.this.dispose();
			}
		});
	}
	public static void main(String[] args) {
		new DaytoDay(1822);
	}
}
